#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2022/6/6 15:09
   @File: open_menu.py
"""
import time
from BladeFerm.hui2_app import FE
from BladeFerm.hui2_app.basic import open_menu_of_search, open_child_system

def open_menu(input_data=None, ui_expect=None):
    '''
    打卡菜单。 '线下客户管理/线下客户管理'
    :param input_data:
        {'子系统名称': '反洗钱系统', '菜单名称': '线下客户管理/线下客户管理'} 或者 {'菜单名称': '线下客户管理'}
    :param ui_expect:
    :return:
    '''
    time.sleep(5)
    # 打开子系统
    child_sys_name = input_data.get('子系统名称', None)
    if child_sys_name:
        open_child_system(child_sys_name)
    # 进入 风险等级查询 菜单
    menu_name = input_data.get('菜单名称')
    menu_name_list = menu_name.split('/')
    if len(menu_name_list) > 1:
        FE.menu().select(menu_name)
    else:
        open_menu_of_search(menu_name)

def arm_form_fill(input_data=None):
    '''
    表单填充的通用功能。
    :param input_data:
    :param ui_expect:
    :return:
    '''
    if input_data:
        keys_list = list(input_data.keys())
        text = keys_list[0] if keys_list else None
    else:
        text = None
    if text:
        search_form = FE.form(text=text)
    else:
        idname = input_data.pop('表单ID', 'mainSearch')
        search_form = FE.form(idname=idname)
    # 表单填入
    search_form.button_option('重置')
    search_form.button_option('查询')
    search_form.auto_fill(input_data)
    search_form.button_option('查询')







